/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hopfield;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author aluno
 */
public class Arquivo {
    
    public Arquivo(){
        
    }

    public ArrayList<int []> leituraArquivo(String tipo) throws IOException{

        String pathName;

        if(tipo.equals("ruidos"))
            pathName = "ruidos.txt";        
        else
            pathName = "padroes.txt";

        try {

            String linha = new String();
            ArrayList<int[]> values = new ArrayList<int[]>();
            BufferedReader fileIn = new BufferedReader(new FileReader(pathName));

            linha = fileIn.readLine();
            
            while(linha != null){

                String[] aux = linha.split(" ");
                int i[] = new int[aux.length];

                for(int j=0; j < aux.length; j++){
                    i[j] = Integer.parseInt(aux[j]);
                }

                values.add(i);                
                linha = fileIn.readLine();                
            }

            return values;

        } catch (FileNotFoundException ex) {
            Logger.getLogger(HopField.class.getName()).log(Level.SEVERE, null, ex);
        }

        return null;
    }
}
